Skip to content

feat: check local branch state when creating comments#533

Open
jakubbortlik wants to merge 2 commits intoharrisoncramer:developfrom
jakubbortlik:fix/check-local-in-sync-before-commenting
Open

feat: check local branch state when creating comments#533
jakubbortlik wants to merge 2 commits intoharrisoncramer:developfrom
jakubbortlik:fix/check-local-in-sync-before-commenting

Conversation

@jakubbortlik
Copy link
Collaborator

Comment creation sometimes crashes when the local branch is not up-to-date with the remote, sometimes a comment is created on the wrong line when the file has been updated on remote.

The out-of-sync state is reported when the reviewer is initiated, but it should be checked more regularly, so this PR introduces checking of "ahead" and "behind" commits:

  • whenever a user tries to create a new comment
  • when the discussion tree is updated

The "ahead" and "behind" commits are now shown in the winbar of the discussion tree. To make it fit more easily, I've changed the section "Inline Comments" to just "Comments".

---@param current_branch string|nil
---@param remote_branch string|nil
---@return integer|nil ahead, integer|nil behind
M.get_ahead_behind = function(current_branch, remote_branch)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is refactored to only get the number of commits and not show warnings to the user so that it can be used more often without annoying the user. The notification is moved up to the check_current_branch_up_to_date_on_remote function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant